package com.smarttest.base


import android.app.Activity
import android.app.Application
import android.app.Fragment
import com.smarttest.dagger.di.DaggerAppComponent
import dagger.android.*
import javax.inject.Inject


//支持activity、fragment注入
class BaseApp : Application(), HasActivityInjector, HasFragmentInjector {
    @Inject
    lateinit var activityInjector: DispatchingAndroidInjector<Activity>
    @Inject
    lateinit var fragmentInjector: DispatchingAndroidInjector<Fragment>

    override fun onCreate() {
        //dagger注入
        DaggerAppComponent.builder().application(this).build().inject(this)
        super.onCreate()
    }

    override fun activityInjector(): AndroidInjector<Activity> = activityInjector

    override fun fragmentInjector(): AndroidInjector<Fragment> = fragmentInjector

}
